<?php

   $latitude = get_input("lat");
   $longitude = get_input("long");
   
   if (empty($latitude) || empty($longitude) ){
      $username = get_input("producer");
      $producer = get_user_by_username($username);
      $longitude = get_metadata_byname($producer->guid, 'address_longitude');
      $latitude = get_metadata_byname($producer->guid, 'address_latitude');
      $longitude = $longitude->value;
   	  $latitude = $latitude->value;
   }
      
   $producers = get_produceres_close($latitude,$longitude, FALSE);

   $params = array ('latitude' => $latitude ,
                    'longitude' => $longitude, 
	                'producers' => $producers);   
	
   if (! isset($producers)){
     	$body = elgg_echo('map_location:empty');
   }
   $map .= elgg_view_title(elgg_echo('map_location:producers_map'));
   $map .= elgg_view('map_location/maps/print',  $params);
   $checkboxes = elgg_view_title(elgg_echo('map_location:category'));
   $checkboxes .= elgg_view('map_location/maps/checkbox_category');
   
   $map =  elgg_view_layout('two_column_left_sidebar',  $checkboxes, $map);
   
   $list = elgg_view('map_location/list',$params );
   
   $body = elgg_view("map_location/tabs", array ('list' => $list,
                                                 'map' => $map));

   $body = elgg_view('page_elements/contentwrapper', array('body' => $body));
   if (! isset($producers)){
      $body = elgg_view_title(elgg_echo('map_location:empty'));
   }
   $title = elgg_echo('map_location:menu'); 
   page_draw($title, $body);
  // */
?>